﻿<!DOCTYPE html>
<?php
    //Load all php files
    include("ClassLoader\loader.php");
    Loader::load();
    
    $command = $_REQUEST['command'];
    switch($command) {
        case "login":
            $model = User::withEmail($_REQUEST["email"]);
            $view = new UserView();
            $controller = new UserController($model, $view);
            $controller->login($_REQUEST["password"]);
            break;
        case "register":
            $email    = $_REQUEST['email'];
            $name     = $_REQUEST['name'];
            $password = $_REQUEST['password'];
            $image    = $_FILES['image'];
            $idDevice = $_REQUEST['idDevice'];
            
            $model = User::withData($idDevice, $name, $password, $email);
            $view = new UserView();
            $controller = new UserController($model, $view);
            $controller->save();
        default:
            break;
    }
    
?>